<?php
/*
 * This is for further use
 * 
 */

class UserRegisterForm extends CFormModel
{
	public $username;
	public $password;
	public $password_confirm;

	private $_identity;

	/**
	 * Declares the validation rules.
	 * The rules state that username and password are required,
	 * and password needs to be authenticated.
	 */
	public function rules()
	{
		return array(
			array('username, password, password_confirm', 'required'),
			array('password', 'compare','compareAttribute'=>'password_confirm'),
		);
	}

	public function register(){
		$h_password = crypt($this->password, $this->password);//User::model()->hashPassword($this->password);
		
		$p = new User();
		$p->user_login = $this->username;
		$p->user_pass = $h_password;
		$p->user_registered = date('Y-m-d H:i:s');
		return $p->save();
		
	}
	
}
